package com.itlong.cloud.controller.sdkV1.old.appClient;


import com.itlong.cloud.enumerate.oldapp.Code;
import com.itlong.cloud.enumerate.oldapp.Message;
import com.itlong.cloud.user.app.IAppOldServeServiceClient;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
* <desc>
*    sdk-APP其它接口（如检测SDK版本）.
* </desc>
*
* @createDate 2017-11-14
*/
@RestController
@RequestMapping("/jiabanjing/interface")
public class SDKAppOldExtraController {

    //日志记录对象
    private static final Logger LOG = LoggerFactory.getLogger(SDKAppOldExtraController.class);

    @Autowired
    IAppOldServeServiceClient iAppOldServeServiceClient; //APP发布信息操作接口


    /**
     * <desc>
     *    APP SDK_获取SDK版本
     * </desc>
     *
     * @param type 应用接入凭证
     * @param sort 应用接入密钥
     * @return 标准格式化响应结果
     * @author LewisLouis
     * @createDate 2017-11-14
     */
    @ResponseBody
    @RequestMapping("/app/version/latest")
    public Message getLatestApp(String type, String sort){
        try {
            if (StringUtils.isEmpty(type) || StringUtils.isEmpty(sort)){
                return  new Message(Code.NOT_PARAM);
            }
            Message message = iAppOldServeServiceClient.getLatestApp(type,sort);
            return message;
        } catch (Exception e) {
            LOG.error(String.format("【SDK_APP_检测SDK版本】{type:%s sort:%s} exception:{%s}", type,sort,e));
            return new Message(Code.ERROR);
        }
    }
}
